import { Addme, FriendInfo, User } from '@entity/user';
import { Axios } from '@axios/base'
import { HttpStatus } from '@axios/base/http_status';

export class UserAddMe extends Axios {

    constructor() {
        super('user/friend');
    }

    /**
     * POST /user/friend/update/method
     */
    async updateAddMethod(data: any): Promise<Boolean> {
        const result = await this.post<Boolean>('/update/method', data);
        return result.status == HttpStatus.SUCCESS ? result.data : false;
    }

    /**
     * GET /user/friend/query/method
     * @param id 用户 id
     */
    async queryAddMethod(id: number): Promise<Addme> {
        const result = await this.get<Addme>('/query/method', {
            params: {
                targetId: id,
            }
        });
        return result.status == HttpStatus.SUCCESS ? result.data : new Addme();
    }
    
    /**
     * GET /user/friend/myFriend
     * @param id 用户 id
     */
     async queryMyFriends(id: number): Promise<Array<FriendInfo>> {
        const result = await this.get<Array<FriendInfo>>('/myFriend', {
            params: {
                id: id,
            }
        });
        return result.status == HttpStatus.SUCCESS ? result.data : [];
    }

}